/**
 * 
 */
package com.demo2do.fms.scheduler.dao.fms;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.demo2do.core.persistence.GenericJdbcSupport;
import com.demo2do.fms.scheduler.entity.Branch;
import com.demo2do.fms.scheduler.entity.Vendor;


/**
 * @author Ysy
 *
 */
@Repository("fmsDaoSupport")
public class FmsDaoSupport {
    
    @Autowired
    private GenericJdbcSupport genericJdbcSupportFms;

    /**
     * 
     * @param branch
     */
    public void saveBranch(Branch branch){
        String insertSentence = "INSERT INTO VW_BRANCH(id, name, code, version, is_disabled) VALUES(:id, :name, :code, :version, :state)";
        Map<String, Object> insertParameters = branch.describe();
        genericJdbcSupportFms.executeSQL(insertSentence, insertParameters);
    }
    
    /**
     * 
     * @param vendor
     */
    public void saveVendor(Vendor vendor){
        
        String insertSentence = "INSERT INTO FMS_VENDOR " 
                + "(id, code, name, short_name, status, deposit, account_playable_days, scope, bank_name, bank_account, tax_number, legal_person, address, zip_code, mobile, fax, main_contactor, second_contactor, "
                + " main_phone, second_phone, main_email, second_email, remark, branch_id, version, attachment, create_time, last_modify_time, creator, last_operator, is_disabled ) "
          + "VALUES "
                + "(:id, :code, :name, :shortName, :status, :deposit, :accountPlayableDays, :scope, :bankName, :bankAccount, :taxNumber, :legalPerson, :address, :zipCode, :mobile, :fax, :mainContactor, :secondContactor, "
                + " :mainPhone, :secondPhone, :mainEmail, :secondEmail, :remark, :branchId, :version, :attachment ,:createTime, :lastModifyTime, :creator, :lastOperator, :disabled ) ";
        
        Map<String, Object> insertParameters = vendor.init().describe();
        genericJdbcSupportFms.executeSQL(insertSentence, insertParameters);
        
    }
}
